package com.wzy.controller;



import com.wzy.order.bean.Order;
import com.wzy.service.OrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;


@RefreshScope
@RestController
public class OrderController {
    @Autowired
    OrderService orderService;

    @Value("${order.timeout}")
    String orderTimeout;


    @Value("${order.auto-confirm}")
    String autoConfirm;


    @GetMapping("/config")
    public String config(){

        return orderTimeout+"\n" + autoConfirm;
    }

    //创建订单
    @GetMapping("/create")
    public Order createOrder(@RequestParam("userId") Long userId,@RequestParam("productId") Long productId){
        Order order = orderService.createOrder(productId, userId);
        return order;
    }
}
